package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.dto.TicketGetDTO;
import com.example.demo.entity.Ticket;
import com.example.demo.service.TicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/v1/ticket")
public class TicketController {
    @Autowired
    private TicketService ticketService;

    @PostMapping
    public Result createTicket(@RequestBody Ticket ticket) {
        return ticketService.addTicket(ticket);
    }

    @GetMapping
    public Result getTickets(TicketGetDTO ticketGetDTO) {
        return ticketService.getTickets(ticketGetDTO);
    }

    @DeleteMapping("/{id}")
    public Result deleteTicket(@PathVariable("id") Integer id) {
        return ticketService.deleteTicket(id);
    }

    @PutMapping
    public Result updateTicket(@RequestBody Ticket ticket) {
        return ticketService.updateTicket(ticket);
    }
}
